import openpyxl
from openpyxl.styles import Font, Fill, Border, Side, PatternFill
# 这个代码用来整理东南西北和专名大写问题
# 打开工作簿
import Capitalize
import main

# workbook = openpyxl.load_workbook(r'D:\Windows\白塔镇加拼音.xlsx')  # 依据哪一个Excel
workbook = openpyxl.load_workbook(r'D:\Windows\新建 XLSX 工作表.xlsx')  # 依据哪一个Excel
excelFileName = "白塔镇加拼音区分东南西北"  # 新生成的Excel名称
excelStrLine = 'A'  # 中文列
excelPyLine = 'D'  # 拼音列
chinese_to_arabic = {'A': 1, 'B': 2, 'C': 3, 'D': 4, 'E': 5, 'F': 6, 'G': 7, 'H': 8, 'I': 9, 'J': 10, 'K': 11,
                     'L': 12, 'M': 13, 'N': 14}
# 获取工作表
sheet = workbook['Sheet1']

# 读取拼音单元格数据
b_column_data = []

# 遍历 A 列的单元格，并进行修改
for row in sheet.iter_rows(min_col=1, max_col=1, min_row=1, max_row=sheet.max_row):
    for cell in row:
        if isinstance(cell.value, str) and cell.value:  # 确保单元格值是字符串且不为空
            new_value = cell.value[:-1] + "巷"  # 删除最后一个字符并添加“巷”
            sheet.cell(row=cell.row, column=2, value=new_value)  # 将结果写入 B 列

workbook.save(rf'D:\Windows\{excelFileName}.xlsx')
